<template>
  <div class="container">
    <h2>How To Create Custom Input Field</h2>
    <!-- novalidate="novalidate" 禁用表单验证 -->
    <form novalidate="novalidate">
        <div class="input-field">
            <input type="text" name="" required="">
            <label>Please Enter Your Full Name</label>
            <span></span>
        </div>
        <input type="submit" value="Show Result" name="" class="btn">
    </form>
  </div>
</template>

<script>
export default {
    data() {
        return {

        }
    },
    components:{

    },
    watch:{

    },
    computed:{

    },
    created() {

    },
    mounted() {

    },
    methods: {
        
    }
}
</script>

<style  scoped>
@import url('http://fonts.googleapis.com/css?family=Poppins:200,300,400,500,600,700&display=swap');
*
{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    outline: none;
    font-family: 'Poppins', sans-serif;
}
body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;

}
.container {
    position: relative;
    width: 500px;
    padding: 40px;
    background-color: #151515;
}
.container h2 {
    color: #999;
    margin-bottom: 45px;
}
.input-field {
    position: relative;
    height: 40px;
    width: 100%;
}
.input-field input[type='text'] {
    position: absolute;
    background: transparent;
    border: none;
    font-size: 16px;
    color: #fff;
    width: 100%;
}
.input-field label {
    position: absolute;
    top:0;
    left: 0;
    color: #555;
    pointer-events: none;
    display: block;
    transition: 0.5s;
}
.input-field input[type='text']:focus + label,
.input-field input[type='text']:valid + label {
    transform: translateY(-35px);
    font-size: 14px;
    color: #fff;
    background-color: #ff006a;
    padding: 2px 6px;
}
.input-field span {
    position: absolute;
    bottom: 0;
    right: 0;
    display: block;
    background: #555;
    width: 100%;
    height: 2px;
}
.input-field span::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #00b0ff;
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.5s ease-in-out;
}
.input-field input[type='text']:focus ~ span::before,
.input-field input[type='text']:valid ~ span::before {
    transform: scaleX(1);
    transform-origin: left;
    transition: transform 0.5s ease-in-out;
}
.btn {
    margin-top: 20px;
    border: none;
    padding: 10px 25px;
    color: #fff;
    font-size: 16px;
    background-color: #333;
    cursor: pointer;
}
.btn:hover {
    background-color: #00bcd4;

}
</style>